package LogicaClasesNew;


import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.ws.Endpoint;


@WebService
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class WsIcliente {
    
    private Endpoint endpoint = null;
    private IcontroladorCliente ICC;

    
    //Constructor que publica el WebService con sus metodos.
    public WsIcliente() {
        
    Fabrica fabrica = Fabrica.getInstance();
    this.ICC = fabrica.getControladorCliente();
    try{
    Properties preferences = new Properties();
    FileInputStream in = new FileInputStream(System.getProperty("user.home")+"/configWebServices.ini");
    preferences.load(in);
    String host = preferences.getProperty("Host");
    String port = preferences.getProperty("Port");
    endpoint = Endpoint.publish("http://"+host+":"+port+"/icliente", this);
    }
    catch(Exception ex){
    //    endpoint = Endpoint.publish("http://localhost:8280/icliente", this);
    }
		
//.....WebMethod.....
    }
    
    @WebMethod
    public void createCliente (String Nickname, String Nombre, String Apellido, String FechNacim, String password, String Mail){
    ICC.createCliente(Nickname, Nombre, Apellido, FechNacim, password, Mail);
    }
    
    @WebMethod(exclude=true)
    public void createCliente2(String Nickname, String Nombre, String Apellido, String FechNacim, String password, String Mail, byte[] Foto){
        ICC.createCliente2(Nickname, Nombre, Apellido, FechNacim, password, Mail, Foto);
    }
    
    @WebMethod
    public Cliente findCliente(String Nickname){
        return ICC.findCliente(Nickname);
    }
    
    @WebMethod
    public ArrayList<Cliente> findClienteEntities(){
        return  new ArrayList(ICC.findClienteEntities());
    }
    
    @WebMethod
    public ArrayList<OrdenCompra> getListadoOrdenesXcli(String nickname){
        return new ArrayList(ICC.getListadoOrdenesXcliente(nickname));
    }
   
    @WebMethod(exclude = true)
	public Endpoint getEndpoint() {
            return endpoint;
    }
    
    @WebMethod
    public void editCliente2(String nickname, boolean notificaciones, boolean notificacioneso){
     ICC.editCliente2(nickname, notificaciones, notificacioneso);
    }
   
}
